
"""
Hardware API is defined here.

Example of usage:

from hardware.api import PulseGenerator
PG = PulseGenerator  

Default hardware api hooks are dummy classes.

Provide a file 'custom_api.py' to define actual hardware API hooks.
This can be imported names, modules, factory functions and factory functions
that emulate singleton behavior.

See 'custom_api_example.py' for examples.
"""

import os
import dummy

############################
# factory functions
############################

from tools.utility import singleton

@singleton
def Scanner():
    return dummy.Scanner(xrange=(0.,100.), yrange=(0.,100.), zrange=(-10.,10.),)

def Counter():
    if not hasattr(Counter, '_counter'):
        Counter._counter = dummy.Counter()
    return Counter._counter

def Microwave():
    return dummy.Microwave()

def RFSource():
    return dummy.RFSource()

def MicrowaveA():
    return dummy.Microwave()

def MicrowaveB():
    return dummy.Microwave()

def PulseGenerator():
    return dummy.PulseGenerator()

import dummy_time_tagger as TimeTagger

# if customized hardware factory is present run it
# Provide this file to overwrite / add your own factory functions, classes, imports
if os.access('hardware/custom_api.py', os.F_OK):
    execfile('hardware/custom_api.py')
